home *** CD-ROM | disk | FTP | other *** search
- /*
- File: EnableEOMSample.c
-
- Contains: Demonstrate the use of the OTOptionManagement call to tell a PAP or
- ADSP endpoint to enable/disable the EOM option.
-
- Note that this sample does not support asynch endpoints. To support
- an asynch endpoint, the same call to OTOptionManagement would happen
- however, the endpoint handler will be called with the
- T_OPTMGMTCOMPLETE event. The handler would then inspect the cookie,
- which will be the TOptMgmt "ret" value to check for the
- success or failure of the call.
-
- Written by: Rich Kubota
-
- Copyright: Copyright © 1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/22/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
-
- #include "OpenTransport.h" // open transport files
- #include "OpenTptAppletalk.h"
-
- extern OSStatus DoNegotiateEOMOption(EndpointRef ep, Boolean enableEOM);
-
- /*
- Sample function to enable/disable the EOM option for
- ADSP. This function also demonstrates the
- use of the OTOptionManagement call.
-
- Unless explicitely defined by XTI, all Open Transport options
- use a kOTFourByteOptionSize buffer.
-
- Input
- EndpointRef ep - endpoint on which to set EOM option on
- Boolean enableEOM - true - option on, false - option off
-
- Return: kOTNoError indicates that the option was successfully negotiated
- OSStatus is an error if < 0, otherwise, the status field is
- returned and is > 0.
-
- */
- OSStatus DoNegotiateEOMOption(EndpointRef ep, Boolean enableEOM)
-
- {
- UInt8 buf[kOTFourByteOptionSize]; // define buffer for fourByte Option size
- TOption* opt; // option ptr to make items easier to access
- TOptMgmt req;
- TOptMgmt ret;
- OSStatus err;
-
- if (OTIsSynchronous(ep) == false) // check whether ep sync or not
- {
- DebugStr("\pThis routine does not support asynch endpoints");
- return (OSStatus)-1;
- }
-
- opt = (TOption*)buf; // set option ptr to buffer
- req.opt.buf = buf;
- req.opt.len = sizeof(buf);
- req.flags = T_NEGOTIATE; // negotiate for EOM option
-
- ret.opt.buf = buf;
- ret.opt.maxlen = kOTFourByteOptionSize;
-
- opt->level = ATK_PAP; // dealing with PAP
- opt->name = OPT_ENABLEEOM;
- opt->len = kOTFourByteOptionSize;
- opt->status = 0;
- *(UInt32*)opt->value = enableEOM; // set the desired option level, true or false
-
- err = OTOptionManagement(ep, &req, &ret);
-
- // if no error then return the option status value
- if (err == kOTNoError)
- {
- if (opt->status != T_SUCCESS)
- err = opt->status;
- else
- err = kOTNoError;
- }
-
- return err;
- }
-